define(function () {
    return function (obtn, goods) {
        for (let i = 0; i < obtn.length; i++) {
            obtn[i].index = i;
            obtn[i].onclick = function () {
                if (this.className === "iconfont icon-gouxuankuang2 btn") {
                    this.className = "iconfont icon-gouxuankuang1 btn";
                    // if (this.index === 0 || this.index === this.chang - 1) {
                    //     for (let j = 0; j < obtn.length; j++) {
                    //         obtn[j].className = "iconfont icon-gouxuankuang1 btn";
                    //     }
                    // }
                    // console.log(this.parentNode.getAttribute("id"))
                    for (let j = 0; j < goods.length; j++) {
                        if (this.parentNode.getAttribute("id") === goods[j].id) {
                            goods[j].status = "icon-gouxuankuang1";
                            localStorage.setItem("goods", JSON.stringify(goods))
                        }
                    }

                } else if (this.className === "iconfont icon-gouxuankuang1 btn") {
                    this.className = "iconfont icon-gouxuankuang2 btn";
                    // if (this.index === 0 || this.index === this.chang - 1) {
                    //     for (let j = 0; j < obtn.length; j++) {
                    //         obtn[j].className = "iconfont icon-gouxuankuang2 btn";
                    //     }
                    // }
                    for (let j = 0; j < goods.length; j++) {
                        if (this.parentNode.getAttribute("id") === goods[j].id) {
                            goods[j].status = "icon-gouxuankuang2";
                            localStorage.setItem("goods", JSON.stringify(goods))
                        }
                    }
                }
                // let str = [];
                // for (let j = 1; j < obtn.length - 1; j++) {
                //     if (obtn[j].className !== "iconfont icon-gouxuankuang1 btn") {
                //         obtn[0].className = "iconfont icon-gouxuankuang2 btn";
                //         obtn[obtn.length - 1].className = "iconfont icon-gouxuankuang2 btn";
                //     } else if (obtn[j].className === "iconfont icon-gouxuankuang1 btn") {
                //         str.push(obtn[j])
                //         if (str.length === obtn.length - 2) {
                //             obtn[0].className = "iconfont icon-gouxuankuang1 btn";
                //             obtn[obtn.length - 1].className = "iconfont icon-gouxuankuang1 btn";
                //         }
                //     }
                // }
            }
        }
    }
})